#!/usr/bin/env bash

set -Eeuox pipefail

readonly CURRENT_FILE_HASH=$(md5sum PhpStormStubsMap.php | awk '{ print $1 }')

# Generate the stub map again
php generate-stub-map

readonly NEW_FILE_HASH=$(md5sum PhpStormStubsMap.php | awk '{ print $1 }')

if [[ "${CURRENT_FILE_HASH}" != "${NEW_FILE_HASH}" ]]; then
    echo "The commited stub map is not up to date. Please regenerate it using ./generate-stub-map";
    cat PhpStormStubsMap.php
    exit 1;
fi
